﻿
@{
    ViewBag.Title = "网站设置";
    Layout = "~/Areas/Manage/Views/Shared/_SubPage.cshtml";
}


@section Header{
    <style type="text/css">
        image {
            max-width: 100%;
        }
    </style>
    <link type="text/css" rel="stylesheet" href="~/Content/vendors/bootstrap-datepicker/css/datepicker.css" />
    <link href="~/Content/vendors/jquery-file-upload/css/jquery.fileupload.css" rel="stylesheet" />
}
@section Footer{
    <script src="~/Content/vendors/ueditor/ueditor.config.js" type="text/javascript"></script>
    <script src="~/Content/vendors/ueditor/ueditor.all.js" type="text/javascript"></script>
    <script src="~/Content/vendors/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script src="~/Content/vendors/jquery-file-upload/js/vendor/jquery.ui.widget.js"></script>
    <script src="~/Content/vendors/jquery-file-upload/js/jquery.iframe-transport.js"></script>
    <script src="~/Content/vendors/jquery-file-upload/js/jquery.fileupload.js"></script>
    <script type="text/javascript">
        var Model = @MvcHtmlString.Create(Newtonsoft.Json.JsonConvert.SerializeObject(ViewBag.Setting));
        var ue = UE.getEditor('container');
        ue.ready(function () {
            $("#edui1").css("zIndex", 9999);
            ue.setContent(Model.FootContent);
        });
        var ejApp = angular.module('ejapp', []);
        ejApp.controller('mainCtrl', function ($scope,$http) {
            $scope.Entity =Model;
            $scope.Entity.tempImageUrl = $scope.Entity.Logo;
            $scope.Entity.tempImageUrl1 = $scope.Entity.ICO;

            $scope.OnSubmit = false;
            $scope.SubmitForm=function (isValid) {
                $scope.OnSubmit=true;
                if (!isValid) { return; }
                $scope.Entity.FootContent = ue.getContent();
                showLoading();
                $http.post("/Manage/SysSetting/Website_Save",$scope.Entity)
                    .success(function(data, status, headers, config){
                        $scope.OnSubmit = false;
                        EJ.showSuccess("操作成功!");
                        hideLoading();
                    })
                    .error(function(data, status, headers, config){
                        $scope.OnSubmit = false;
                        EJ.showError("远程服务器错误");
                        hideLoading();
                    });
            };
            $scope.$watch('Entity.tempImageUrl', function () {
                var url = '';
                if ($scope.Entity.tempImageUrl) {
                    url = $scope.Entity.tempImageUrl;
                }
                $("#imgPreview").attr('src', url);
                $("#aPreview").attr('href', url);
            });
            $scope.$watch('Entity.tempImageUrl1', function () {
                var url = '';
                if ($scope.Entity.tempImageUrl1) {
                    url = $scope.Entity.tempImageUrl1;
                }
                $("#imgPreview1").attr('src', url);
                $("#aPreview1").attr('href', url);
            });

            //图片上传
            $scope.upload = function () {
                $('#fileupload').fileupload({
                    url: '/Manage/SysSetting/UploadPics',
                    dataType: 'json',
                    success: function (data) {
                        if (data.Success) {
                            var url = data.Model[0];
                            $scope.$apply(function () {
                                $scope.Entity.tempImageUrl = url;
                            });
                        } else {
                            EJToastr.error(data.Message);
                        }
                    },
                    progressall: function (e, data) {
                        var progress = parseInt(data.loaded / data.total * 100, 10);
                        $('#progress .progress-bar').css(
                            'width',
                            progress + '%'
                        );
                    }
                }).prop('disabled', !$.support.fileInput)
            .parent().addClass($.support.fileInput ? undefined : 'disabled');
            }
            $scope.resetUpload = function () {   //重置图片
                $scope.Entity.tempImageUrl = $scope.Entity.Logo;
            }
            //图片上传
            $scope.upload1 = function () {
                $('#fileupload1').fileupload({
                    url: '/Manage/SysSetting/UploadICO',
                    dataType: 'json',
                    success: function (data) {
                        if (data.Success) {
                            var url = data.Model[0];
                            $scope.$apply(function () {
                                $scope.Entity.tempImageUrl1 = url;
                            });
                        } else {
                            EJToastr.error(data.Message);
                        }
                    },
                    progressall: function (e, data) {
                        var progress = parseInt(data.loaded / data.total * 100, 10);
                        $('#progress .progress-bar').css(
                            'width',
                            progress + '%'
                        );
                    }
                }).prop('disabled', !$.support.fileInput)
            .parent().addClass($.support.fileInput ? undefined : 'disabled');
            }
            $scope.resetUpload1 = function () {   //重置图片
                $scope.Entity.tempImageUrl1 = $scope.Entity.ICO;
            }
        });
    </script>
}
<div class="wrapper wrapper-content animated fadeInUp">
    <div class="row  animated slideInRight">
        <div class="col-sm-12">
            <div class="tabs-container">
                <ul class="nav nav-tabs">
                    <li class="active">
                        <a data-toggle="tab" href="#tab-1" aria-expanded="true">网站全局属性</a>
                    </li>
                    <li class="">
                        <a data-toggle="tab" href="#tab-2" aria-expanded="false">网站图片文件</a>
                    </li>
                    <li class="">
                        <a data-toggle="tab" href="#tab-3" aria-expanded="false">网站底部HTML</a>
                    </li>
                </ul>
                <form name="mainForm" ng-submit="SubmitForm(mainForm.$valid)" class="form-horizontal form-bordered form-row-stripped" role="form" novalidate>
                    <div class="tab-content">
                        <div id="tab-1" class="tab-pane active">
                            <div class="panel-body">
                                <div class="col-sm-12">
                                    <div class="ibox float-e-margins">
                                        <div class="ibox-content">
                                            <div class="form-group" ng-class="{ 'state-error' : mainForm.MallName.$invalid&&OnSubmit}">
                                                <label for="MallName" class="col-md-2 control-label">
                                                    网站名称:
                                                </label>
                                                <div class="col-md-10">
                                                    <input name="MallName" type="text" ng-model="Entity.MallName" class="form-control" ng-required="true" />
                                                    <em for="MallName" ng-show="mainForm.MallName.$invalid&&OnSubmit" class="invalid">必填字段</em>
                                                </div>
                                            </div>
                                            <div class="hr-line-dashed"></div>
                                            <div class="form-group" ng-class="{ 'state-error' : mainForm.ManageTitle.$invalid&&OnSubmit}">
                                                <label for="ManageTitle" class="col-md-2 control-label">
                                                    后台名称:
                                                </label>
                                                <div class="col-md-10">
                                                    <input name="ManageTitle" type="text" ng-model="Entity.ManageTitle" class="form-control" ng-required="true" />
                                                    <em for="ManageTitle" ng-show="mainForm.ManageTitle.$invalid&&OnSubmit" class="invalid">必填字段</em>
                                                </div>
                                            </div>
                                            <div class="hr-line-dashed"></div>
                                            <div class="form-group">
                                                <label for="SEODescription" class="col-md-2 control-label">
                                                    keywords:
                                                </label>
                                                <div class="col-md-10">
                                                    <textarea rows="3" name="SEODescription" maxlength="100" ng-model="Entity.Keywords" class="form-control"></textarea>
                                                </div>
                                            </div>
                                            <div class="hr-line-dashed"></div>
                                            <div class="form-group">
                                                <label for="SEODescription" class="col-md-2 control-label">
                                                    Description(描述):
                                                </label>
                                                <div class="col-md-10">
                                                    <textarea rows="3" maxlength="200" name="Description" ng-model="Entity.Description" class="form-control"></textarea>
                                                </div>
                                            </div>
                                            <div class="hr-line-dashed"></div>
                                            <div class="form-group">
                                                <div class="col-sm-8 col-sm-offset-2">
                                                    <button class="btn btn-primary" type="submit">保存内容</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div id="tab-2" class="tab-pane">
                            <div class="panel-body">
                                <div class="col-sm-12">
                                    <div class="ibox float-e-margins">
                                        <div class="ibox-content">
                                            <div class="form-group">
                                                <label for="SiteTitle" class="col-md-2 control-label">
                                                    LOGO:
                                                </label>
                                                <div class="col-md-10">
                                                    <div class="row">
                                                        <div class="col-md-3">
                                                            <div class="form-group">
                                                                <label class="control-label"></label>
                                                                <div class="img thumbnail" style="width: 200px; height: 160px; overflow:hidden">
                                                                    <a id="aPreview" href="" data-lightbox="image-item-newitem">
                                                                        <img id="imgPreview" class="img-responsive" />
                                                                    </a>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-6">

                                                            <div class="form-group">
                                                                <label class="control-label">路径:</label>
                                                                <input ng-readonly="true" type="text" class="form-control" ng-model="Entity.tempImageUrl" />
                                                            </div>
                                                            <div class="form-group" ng-class="{ 'state-error' : mainForm.LogoWidth.$invalid&&OnSubmit}">
                                                                <label for="LogoWidth" class="col-md-2 control-label">
                                                                    宽度:
                                                                </label>
                                                                <div class="col-md-10">
                                                                    <input name="LogoWidth" type="text" ng-model="Entity.LogoWidth" class="form-control" ng-required="true" />
                                                                    <em for="LogoWidth" ng-show="mainForm.LogoWidth.$invalid&&OnSubmit" class="invalid">必填字段</em>
                                                                </div>
                                                            </div>
                                                            <div class="form-group" ng-class="{ 'state-error' : mainForm.LogoHeight.$invalid&&OnSubmit}">
                                                                <label for="LogoHeight" class="col-md-2 control-label">
                                                                    宽度:
                                                                </label>
                                                                <div class="col-md-10">
                                                                    <input name="LogoHeight" type="text" ng-model="Entity.LogoHeight" class="form-control" ng-required="true" />
                                                                    <em for="LogoHeight" ng-show="mainForm.LogoHeight.$invalid&&OnSubmit" class="invalid">必填字段</em>
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <span class="btn btn-success fileinput-button" ng-click="upload()">
                                                                    <i class="glyphicon glyphicon-plus"></i>
                                                                    <span>上传图片</span>
                                                                    <input id="fileupload" type="file" name="files[]">
                                                                </span>
                                                                <span class="btn btn-warning" ng-click="resetUpload()">
                                                                    <i class="glyphicon glyphicon-plus"></i>
                                                                    <span>重置图片</span>
                                                                </span>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="hr-line-dashed"></div>
                                            <div class="form-group">
                                                <label for="SiteTitle" class="col-md-2 control-label">
                                                    ICO:
                                                </label>
                                                <div class="col-md-10">
                                                    <div class="row">
                                                        <div class="col-md-3">
                                                            <div class="form-group">
                                                                <label class="control-label"></label>
                                                                <div class="img thumbnail" style="width: 200px; height: 160px; overflow:hidden">
                                                                    <a id="aPreview1" href="" data-lightbox="image-item-newitem">
                                                                        <img id="imgPreview1" class="img-responsive" />
                                                                    </a>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-6">
                                                            <div class="form-group">
                                                                <label class="control-label">路径:</label>
                                                                <input ng-readonly="true" type="text" class="form-control" ng-model="Entity.tempImageUrl1" />
                                                                <div class="m-t">
                                                                    <span class="btn btn-success fileinput-button" ng-click="upload1()">
                                                                        <i class="glyphicon glyphicon-plus"></i>
                                                                        <span>上传图标</span>
                                                                        <input id="fileupload1" type="file" name="files[]">
                                                                    </span>
                                                                    <span class="btn btn-warning" ng-click="resetUpload1()">
                                                                        <i class="glyphicon glyphicon-plus"></i>
                                                                        <span>重置图片</span>
                                                                    </span>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="hr-line-dashed"></div>
                                            <div class="form-group">
                                                <div class="col-sm-4 col-sm-offset-2">
                                                    <button class="btn btn-primary" type="submit">保存内容</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div id="tab-3" class="tab-pane">
                            <div class="panel-body">
                                <div class="col-sm-12">
                                    <div class="ibox float-e-margins">
                                        <div class="ibox-content">
                                            <div class="row">
                                                <div class="col-sm-12">
                                                    <div class="form-group">
                                                        <label class="control-label">内容:</label>
                                                        <div style="width:100%;">
                                                            <script id="container" name="content" type="text/plain">
                                                            </script>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="hr-line-dashed"></div>
                                            <div class="form-group">
                                                <div class="col-sm-4">
                                                    <button class="btn btn-primary" type="submit">保存内容</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>